import { watch } from 'vue'
import type { Store } from '../types'

export const useWatch = (store: Store) => {
  /** 接口文件变化后，重置接口选择表单 */
  watch(
    () => store.basicFormData.apiFilePath,
    () => {
      store.apiFormData = {
        listPage: ''
      }
    },
    {
      deep: true
    }
  )

  /** 选择的列表接口变化后，重置listPage配置 */
  watch(
    () => store.apiFormData.listPage,
    () => {
      store.listPageFormData = {
        rowKey: ''
      }
    },
    {
      deep: true
    }
  )
}
